/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package handler;

import database.DatabaseHandler;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Calendar;
import javax.swing.ImageIcon;
import model.Menu;
import model.Produkt;
import model.Sandwich;

/**
 *
 * @author Jeppe
 */
public class MenuHandler {

    private final DatabaseHandler databaseHandler;
    private final static boolean DEBUGMODE = true;

    protected MenuHandler() {
        databaseHandler = DatabaseHandler.getInstance();
    }

    
    public Menu getMenuByDate(String cal) throws SQLException{
        Menu enMenu = new Menu(null);
        ResultSet rs = databaseHandler.select("Call getMenuByDate('"+cal+"')");    
        while(rs.next()){
            if(rs.getString("produktType").equalsIgnoreCase("Sandwich")){
                enMenu.addProdukt(new Sandwich(rs.getInt("produktid"), rs.getString("navn"), rs.getInt("pris"), new ImageIcon(rs.getString("picturepath")), rs.getString("beskrivelse"), rs.getInt("rating")));
            }
//            enMenu.addProdukt(new Produkt(rs.getInt("produktid"), rs.getString("navn"), rs.getInt("pris"), new ImageIcon(rs.getString("picturepath")), rs.getString("beskrivelse"), rs.getInt("rating")));
        }
        System.out.println(enMenu.getProduktList().size()+" produkter på menuen");
        return enMenu;
    }
}
